<?php
class Aboutus extends CI_Controller
{
    function __construct ()
    {
        // load controller parent
        parent::__construct();
        $this->load->model('ContentsM');
         //$this->output->enable_profiler(TRUE);
    }
    function index ()
    {
        $data['current_dein'] = 'aboutus';
        $row = $this->ContentsM->getContentsWhere("id", 1);
        $data['aboutus'] = $row[0];
        $this->load->helper('ckeditor');
        $data['ckeditor'] = $this->_initCKEditor();
        //	    
        $this->load->view('admin/header_view', $data);
        $this->load->view('admin/admin_aboutus_edit', $data);
        $this->load->view('admin/footer_view', $data);
    }
    function save ()
    {
        $doSave = $this->input->post('save');
        if (! isset($doSave)) {
            $this->index();
            return;
        }
        $dataSave = array('content' => $this->input->post('description'), 
        'type' => 1);
        $this->db->where('id',1);	
    	$this->db->update('contents',$dataSave);
    	if ($this->db->_error_message()=='')
           $data['success']="Данните са записани успешно!!!";
        else
           $data['error']="Грешка при работа с базата данни!!!";
        
         redirect('/admin/aboutus');
            //return;
    }
    /**
     * Enter description here ...
     * @param data
     */
    function _initCKEditor ()
    {
        /*********** inicialize  CKEditor *********/
        //Ckeditor's configuration
        $data = array(//ID of the textarea that will be replaced
        'id' => 'description', 
        'path' => 'js/ckeditor', 
        //Optionnal values
        'config' => array(
        'toolbar' => array(
        array('Source','Preview', '-', 'Bold', 'Italic', 'Underline', 'Strike')
        , array('JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock')
        )//,	      array( 'Image', 'Link', 'Unlink', 'Anchor' )
        , 
        //"Basic",//"Full", 	//Using the Full toolbar
        'width' => "750px", //Setting a custom width
'height' => '500px', //Setting a custom height
'uiColor' => '#AACFE4', 
        'toolbarStartupExpanded' => FALSE, 'resize_enabled' => false))//Replacing styles from the "Styles tool"
        //			'styles' => array(
        // 
        //				//Creating a new style named "style 1"
        //				'style 1' => array (
        //					'name' 		=> 	'Blue Title',
        //					'element' 	=> 	'h2',
        //					'styles' => array(
        //						'color' 	=> 	'Blue',
        //						'font-weight' 	=> 	'bold'
        //					)
        //				),
        // 
        //				//Creating a new style named "style 2"
        //				'style 2' => array (
        //					'name' 	=> 	'Red Title',
        //					'element' 	=> 	'h2',
        //					'styles' => array(
        //						'color' 		=> 	'Red',
        //						'font-weight' 		=> 	'bold',
        //						'text-decoration'	=> 	'underline'
        //					)
        //				)				
        //			)
        ;
        return $data;
    /*********** end CKEditor inicialization **/
    }
}
?>